<template>
  <div>
    <el-dialog v-loading.lock="loading"
      :append-to-body="true"
      :title="title"
      align="center"
      :close-on-click-modal="false"
      :visible.sync="innerDialogFormVisible"
      @closed="closeDialog">
      <p slot="title">{{ title }}</p>
      <el-form ref="formData"
        :model="formData"
        :rules="formDataRules"
        label-width="120px"
        status-icon>
        <el-row>
          <el-col :span="24">
            <el-form-item label="重量"
              prop="residualWeight">
              <el-input v-model="formData.residualWeight"
                placeholder="请输入重量（克）"
                autocomplete="off"
                min="0"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer"
        class="dialog-footer"
        align="center">
        <el-button type="primary"
          @click="onSubmit('formData')">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "StorageOrderInResidualWeight",
  components: {
  },
  props: {
    dialogResidualWeightVisible: {
      type: Boolean,
      default: false,
    }
  },
  data() {
    return {
      title: '批量设置重量',
      loading: false,
      innerDialogFormVisible: false,
      formData: {
        residualWeight: ''
      },
      formDataRules: {
        residualWeight: [
          {
            required: true,
            trigger: "blur",
            validator: this.Helper.validateFunctionPositiveFloatNumber,
          },
        ]
      }
    };
  },
  watch: {
  },
  created() {
    this.innerDialogFormVisible = this.dialogResidualWeightVisible;
  },
  methods: {
    cancel() {
      this.innerDialogFormVisible = false;
      this.$emit("update:dialogResidualWeightVisible", false);
    },
    closeDialog() {
      this.cancel();
    },
    onSubmit() {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.$emit('batchSetResidualWeight', { residualWeight: this.formData.residualWeight });
          this.closeDialog();
        }
      })
    }
  },
};
</script>
<style lang="scss"></style>
